<%@ include file="header.jsp" %>
<h1>Contest List </h1>
<table>
<tr>
	<td>ID</td>
	<td>Nombre</td>
	<td>Fecha Inicio</td>
	<td>Fecha Fin</td>
	<c:if test="$(userInfo == 1)">
	<td>Inscribir</td>
	</c:if>
</tr>

<c:forEach items="${contestform}" var="contest">
	<tr>
	<td>
	<c:out value="${contest.id}"/>
	</td>
	<td>
	<a href="contestReport.html?contestId=<c:out value="${contest.id}"/>"><c:out value="${contest.name}"/></a>
	</td>
	<td>
	<c:out value="${contest.beginDate}"/>
	</td>
	<td>
	<c:out value="${contest.endDate}"/>
	</td>
	<c:if test="${userInfo.role == 1}">
	<td>	
	<c:set var="sessiona"value="falso"/>
	<c:forEach items="${contest.participants}" var="participante">
		<c:if test="${sessionScope.x eq participante.username}">
			<c:set var="sessiona" value="verdad"/>	
		</c:if>		
	</c:forEach>
	<c:choose>
	<c:when test="${sessiona == 'verdad'}">ya Inscrito</c:when>
	<c:otherwise>
		<a href="signupContest.html?contestId=<c:out value="${contest.id}"/>">Inscribir examen</a>
	</c:otherwise>
	</c:choose>
	</td>
	</c:if>
	</tr>
</c:forEach>
</table>
<%@ include file="footer.jsp" %>